package com.bfxy.disruptor.common.producer;

import com.bfxy.disruptor.common.Cursored;
import com.bfxy.disruptor.common.DataProvider;
import com.bfxy.disruptor.common.event.EventPoller;
import com.bfxy.disruptor.common.Sequenced;
import com.bfxy.disruptor.common.balance.Sequence;
import com.bfxy.disruptor.common.balance.SequenceBarrier;
//发射器，生产者。生产者唯一存在竞争的地方在于获取sequence；
//生产者与RingBuffer之间的桥梁,
public interface Productor extends Cursored, Sequenced
{
    /** Set to -1 as sequence starting point */
    long INITIAL_CURSOR_VALUE = -1L;

    void claim(long sequence);

    boolean isAvailable(long sequence);

    void addGatingSequences(Sequence... gatingSequences);

    boolean removeGatingSequence(Sequence sequence);

    SequenceBarrier newBarrier(Sequence... sequencesToTrack);

    long getMinimumSequence();

    long getHighestPublishedSequence(long nextSequence, long availableSequence);

    <T> EventPoller<T> newPoller(DataProvider<T> provider, Sequence...gatingSequences);
}